<?php

define("ENCRYPTION_KEY", "!@#$%^&*");

class Crypt{

	function Crypt(){
		
	}

	function encrypt($pure_string) {
		$iv_size = mcrypt_get_iv_size(MCRYPT_BLOWFISH, MCRYPT_MODE_ECB);
		$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
		$encrypted_string = mcrypt_encrypt(MCRYPT_BLOWFISH, ENCRYPTION_KEY, utf8_encode($pure_string), MCRYPT_MODE_ECB, $iv);
		return base64_encode($encrypted_string);
	}
	
	/**
	 * Returns decrypted original string
	 */
	function decrypt($encrypted_string) {
		$encrypted_string=base64_decode($encrypted_string);
		$iv_size = mcrypt_get_iv_size(MCRYPT_BLOWFISH, MCRYPT_MODE_ECB);
		$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
		$decrypted_string = mcrypt_decrypt(MCRYPT_BLOWFISH, ENCRYPTION_KEY, $encrypted_string, MCRYPT_MODE_ECB, $iv);
		return $decrypted_string;
	}
}